<?php

require_once '../include/init.php';

$id = isset($_GET['id']) ? $_GET['id'] : '';

$notfound = array(
    'error' => 404,
    'message' => 'resource not found!'
);

try
{
    $object = Nuo::getObject($id);

    if (!is_object($object))
    {
        echo json_encode($notfound);
    }
    else
    if (method_exists($object, 'toObject'))
    {
        echo json_encode($object -> toObject());
    }
    else
    if (method_exists($object, 'toArray'))
    {
        echo json_encode($object -> toArray());
    }
    else
    {
        echo var_export($object, 1);
    }

}
catch(Exception $e)
{
    echo json_encode($notfound);
}
